package com.lagou.controller;

import com.lagou.service.FileService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author fxz
 */
@AllArgsConstructor
@RequestMapping("/file")
@RestController
@CrossOrigin
public class FxzFileController {

    private final FileService fileService;

    @PostMapping("/upload")
    public String upload(@RequestParam("file") MultipartFile file) {
        String path = "";
        try {
            path = fileService.saveFile(file);
            System.out.println(path);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return path;
    }

}
